package com.cloudstudy.config;

import com.cloudstudy.listener.AppListener;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebServerConfig {

    //注册三大组件
    //@Bean
    public ServletRegistrationBean myServlet(){
        //ServletRegistrationBean registrationBean = new ServletRegistrationBean(new MyServlet(),"/myServlet");
        //registrationBean.setLoadOnStartup(1);
        return null;
    }

    //@Bean
    public FilterRegistrationBean myFilter(){
        //FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        //registrationBean.setFilter(new MyFilter());
        //registrationBean.setUrlPatterns(Arrays.asList("/hello","/myServlet"));
        return null;
    }

    @Bean
    public ServletListenerRegistrationBean myListener(){
        ServletListenerRegistrationBean<AppListener> registrationBean = new ServletListenerRegistrationBean<>(new AppListener());
        return registrationBean;
    }

}
